<template>
	<!--通告详细-->
	<view class="page-content">
		<view class="page-body">
			<view class="input-row">
				<input class="input-row-w" type="text" v-model="params.title" placeholder="请输入标题"
					placeholder-style="color:#ccc"></input>
			</view>
			<view class="input-row2">
				<textarea class="input-row-w" v-model="params.content" placeholder-style="color:#ccc" placeholder="请输入内容" />
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
		addNotices
	} from '@/common/api.js';
	export default {
		components: {},
		data() {
			return {
				params: {
					company_id: '',
					title: '',
					content: ''
				}
			}
		},
		computed: {
			...mapGetters(['companyInfo', 'selIndex'])
		},
		onLoad(option) {
			console.log(222, option)
		},
		onNavigationBarButtonTap(e) {
			console.log(23, e)
			if (e.index == 0) {
				this.onsave();
			}
		},
		methods: {
			onsave(){
				this.params.company_id = this.companyInfo.id;
				let resdata = this.params;
				if (resdata.title === "") {
					uni.showToast({
						title: "标题不能为空！",
						icon: 'none',
						duration: 2000
					})
					return;
				}
				if (resdata.content === "") {
					uni.showToast({
						title: "内容不能为空！",
						icon: 'none',
						duration: 2000
					})
					return;
				}
				addNotices(resdata).then(res=>{
					if(res.code === 2000){
						uni.navigateBack({
							delta:1
						})
						setTimeout(() => {
						    uni.showToast({
						    	title:'发布成功！',
						    	icon:'none',
						    	duration:2000
						    })
						}, 100)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.page-content {
		width: 100vw;
		height: 100%;
		background: $uni-bg-color-grey;

		.page-body {
			display: flex;
			flex-direction: column;
			background: $uni-bg-color;

			.input-row {
				margin: 0 30rpx;
				padding: 20rpx 0;
				height: 100rpx;
				display: flex;
				align-items: center;
				width: 100%;
				flex-direction: row;
				border-bottom: 1rpx solid #f5f5f5;

				.input-row-w {
					height: 60rpx;
					display: flex;
					flex: 1;
					width: 100%;
					color: $font-color-3;
					font-size: 32rpx;
				}
			}

			.input-row2 {
				margin: 0 30rpx;
				padding: 20rpx 0;
				height: 360rpx;
				display: flex;
				width: 100%;
				flex-direction: row;
				border-bottom: 1rpx solid #f5f5f5;

				.input-row-w {
					display: flex;
					height: 320rpx;
					flex: 1;
					width: 100%;
					color: $font-color-3;
					font-size: 32rpx;
				}
			}
		}
	}
</style>
